<h1>Good books</h1>


<% form_tag books_path, :method => :get do %>
<p>
	<%= text_field_tag :search, params[:search] %>
	<%= submit_tag "Chercher" %>
</p>
<% end %>

<%= will_paginate(@books) %>

<% for book in @books %>
  	<p>
  		<strong><%= link_to (h book.title), book %></strong> <br />
			<%= h book.author %> 
				| <%= link_to 'Edit', edit_book_path(book) %>
    		|	<%= link_to 'Destroy', book, :confirm => 'Are you sure?', :method => :delete %>
<% end %>

<ul>
	<li><%= link_to "Les livres empruntés", borrowed_books_path() %></li>
	<li><%= link_to "Send newsletter", { :controller => "newsletter", :action => "send_monthly_newsletter" } %></li>
	<li><%= link_to 'New book', new_book_path %></li>
</ul>

			
<div id="books"></div>

<%= link_to_remote("Rafraîchir la liste des livres", :update => "books",
    :url => { :action => "list_ajax" }) %>

<!-- 
	<a onclick="new Ajax.Updater('books', '/books/list_ajax', 
		{asynchronous:true, evalScripts:true, parameters:'authenticity_token=' 
		     + encodeURIComponent('e009111ce09d5aea22b8a841e04dd1c73ecfaf03')}); 
		 return false;" href="#">
		 Rafraîchir la liste des livres
	</a>
	
-->	
<% form_remote_tag :url => '/books/list_ajax', :update => "books" do %>
  <p><%= submit_tag "Hop" %></p>
<% end %>

<!-- Génère le formulaire suivant
  <form action="/books/list_ajax" 
			  method="post" 
				onsubmit="new Ajax.Updater('books', '/books/list_ajax', 
					{asynchronous:true, evalScripts:true, parameters:Form.serialize(this) 
					+ '&amp;authenticity_token=' + encodeURIComponent('e009111ce09d5aea22b8a841e04dd1c73ecfaf03')}); 
					return false;">
					<div style="margin:0;padding:0">
					<input name="authenticity_token" type="hidden" value="e009111ce09d5aea22b8a841e04dd1c73ecfaf03" /></div>
    <p><input name="commit" type="submit" value="Save changes" /></p>
  </form>
-->


